package exer;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author tongchen
 * @create 2023-04-02 16:37
 */
@WebServlet("/refresh")
public class Refresh extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置请求数据的编码集
        req.setCharacterEncoding("utf-8");
        //设置响应数据的格式

        resp.setContentType("application/json;charset=utf-8");
        //设置编码格式
        //测试refresh并通过结果显示变化
        resp.setHeader("refresh", "1");
        resp.getWriter().write("当前时间为"+System.currentTimeMillis());
    }
}
